const { SuccessModel, ErrorModel } = require('../model/ResModel')
const { createBlog } = require('../services/blog')
const xss = require('xss')

async function create({ content, image, userId }) {
  try {
    const res = await createBlog({ content: xss(content), image, userId })
    return new SuccessModel(res)
  } catch (err) {
    console.error(err.message, err.stack)
    return ErrorModel.createBlogFailInfo()
  }
}

module.exports = {
  create
}